<?php

namespace App\Exports\Sheet;

use App\Models\DemoModel;
use Illuminate\Database\Eloquent\Collection;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithTitle;

class DemoSheet implements FromCollection, WithTitle, WithHeadings, WithColumnFormatting, WithColumnWidths, WithStyles
{

    use SheetTrait;

    public function __construct()
    {

        $this->title = 'A';
        $this->columns = $this->myColumns();
    }


    public function collection(): Collection
    {
        return DemoModel::all();
    }

    private function myColumns(): array
    {
        return [
            'A' => 'ID',
            'B' => 'name',
            'C' => 'email',
            'D' => 'email_verified_at',
            'E' => 'password',
            'F' => 'remember_token',
            'G' => 'created_at',
            'H' => 'updated_at',
        ];
    }
}
